# -*- coding;utf-8 -*-
"""
File name : tasks.py.PY
Program IDE : PyCharm
Create file time: 2023/10/17 8:13
File Create By Author : 朱清闯
"""
from celery_tasks.main import app
from account.serializers import NotificationModelSerializer


# 调用 app实例对象的task方法, 装饰这个 函数任务,可以设置name参数
@app.task(name='create_send_notification')
def create_send_notification(user, content):
    print("异步创建通知记录")
    data = {
        'user': user,
        'content': content,
    }
    serializer = NotificationModelSerializer(data=data)
    if serializer.is_valid():
        serializer.save()
    else:
        print('异步创建通知记录error', serializer.errors)

